#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

template<typename T=int>
inline T read() {
    T x;
    cin >> x;
    return x;
}

const int maxn = 1e5 + 500;
int a[maxn], n;
int best = INT_MIN;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; i++)cin >> a[i];
    for (int left = 0; left < n; ++left) {//O(n^3)
        for (int right = left; right < n; ++right) {
            //sum
            int sum = 0;
            for (int k = left; k <= right; k++) {
                sum += a[k];
            }
            if (sum > best)best = sum;
        }
    }
    cout << best;
    return 0;
}
